package grex.fitnessfunctions.Regression;

import grex.GP;
import grex.Prediction;
import grex.fitnessfunctions.FitnessFunction;
import grex.fitnessfunctions.IFitnessFunction;
import grex.genes.GeneException;

import java.io.Serializable;

/**
 *
 * @author rik
 */
public class MAE_Fitness extends FitnessFunction implements IFitnessFunction, Serializable{

    public MAE_Fitness() {
        super(FitnessFunction.MAE);
    }
   public MAE_Fitness(String name,Double instanceKey) {
        super(name,instanceKey);
    }


    @Override
    protected double calcPredictionError(Prediction prediction, double targetValue) {
        return Math.abs(prediction.getPrediction()-targetValue);
    }
    
    @Override        
    protected double normalizeTotalError(double totalError){
        return (totalError / getNrOfInstances()) / getAverageActualValue();
    }
   /* protected double normalizeTotalError(double totalError){
        return totalError / getTotalActualValue();
    }*/
    

}
